# include <bits/stdc++.h>
# include <unordered_map>
using namespace std;
int getMaxNum(vector<int> arr,int size) {
	unordered_map<int,int> map;
	int minNum=INT_MAX;
	for(int i=0; i<size; ++i) {
		map[arr[i]]++;
		minNum=min(minNum,arr[i]);
	}
	while(map[minNum]%(minNum+1)==0) {
		map[minNum+1]+=map[minNum]/(minNum+1);
		map[minNum]=map[minNum]/(minNum+1);
		minNum+=1;
	}
	return minNum;
}
int main() {
	int n;
	cin>>n;
	vector<int> arr(n);
	for(int i=0; i<n; ++i) {
		cin>>arr[i];
	}
	cout<<getMaxNum(arr,n);
	return 0;
}
